﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using RemoteTestRunner.BusinessLogic.Views;
using RemoteTestRunner.Contracts;
using RemoteTestRunner.BusinessLogic.ViewModels;

namespace RemoteTestRunner.FormsUI.Wpf
{
    /// <summary>
    /// Interaction logic for Admin.xaml
    /// </summary>
    public partial class ProjectAdmin : Window, IAdminView
    {
        public ProjectAdmin()
        {
            InitializeComponent();
        }

        #region IAdminView Members

        public void SetRootDataContext(object dataContext)
        {
            this.DataContext = dataContext;
        }

        #endregion

        private void tvwProjects_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            {
                ProjectViewModel selectedProject = e.NewValue as ProjectViewModel;
                if (selectedProject != null)
                {
                    BusinessLogic.ViewModels.ProjectAdminViewModel context =
                        DataContext as BusinessLogic.ViewModels.ProjectAdminViewModel;
                    context.SelectedProject = selectedProject;
                }
            }

            {
                TestViewModel selectedTest = e.NewValue as TestViewModel;
                if (selectedTest != null)
                {
                    BusinessLogic.ViewModels.ProjectAdminViewModel context =
                        DataContext as BusinessLogic.ViewModels.ProjectAdminViewModel;
                    context.SelectedTest = selectedTest ;
                }
            }
        }
    }
}
